import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-07-08
 * Time: 14:04
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        int[]arr1=new int[a];
        for (int i = 0; i < a; i++) {
            arr1[i]=scanner.nextInt();
        }
        int[]arr2=new int[b];
        for (int i = 0; i < b; i++) {
            arr2[i]=scanner.nextInt();
        }
        for (int i = 0; i < b; i++) {

            if( Arrays.binarySearch(arr1,arr2[i])>=0){
            System.out.print( Arrays.binarySearch(arr1,arr2[i])+" ");
        }else{
                System.out.print("-1"+" ");
            }
        }
    }
    public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int[]arr=new int[a];
        for (int i = 0; i < a; i++) {
            arr[i]=scanner.nextInt();
        }
        Arrays.sort(arr);
        for (int x:arr){
            System.out.print(x+" ");
        }
    }
    public static void main1(String[] args) {
        //小玉买铅笔
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        double c=(a+0.1*b)/1.9;
        System.out.println((int)c);
    }
}